package com.flynn.rock.crm.controller;

import com.flynn.rock.annotation.OperateLog;
import com.flynn.rock.crm.model.customer.request.AutoDispatchOrderRequest;
import com.flynn.rock.crm.model.customer.vo.AutoDispatchOrderVo;
import com.flynn.rock.crm.service.CrmConfigService;
import com.flynn.rock.enums.BusinessType;
import com.flynn.rock.enums.OperateType;
import com.flynn.rock.model.Response;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/crm/config")
@AllArgsConstructor
@Tag(name = "配置管理")
public class CrmConfigController {

    private CrmConfigService crmConfigService;

    @GetMapping("/autoDispatchOrder")
    @Operation(summary = "查询自动派单配置信息")
    public Response<AutoDispatchOrderVo> getAutoDispatchOrderConfig() {
        return Response.success(crmConfigService.getAutoDispatchOrderConfig());
    }

    @OperateLog(operateTitle = "编辑自动派单配置信息", operateType = OperateType.UPDATE, businessType = BusinessType.CRM)
    @PostMapping("/autoDispatchOrder")
    @Operation(summary = "编辑自动派单配置信息")
    public Response<Void> editAutoDispatchOrderConfig(@RequestBody AutoDispatchOrderRequest request) {
        crmConfigService.editAutoDispatchOrderConfig(request);
        return Response.success(null);
    }
}
